package svc

import (
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"storage/internal/config"
	"storage/models"
)

type ServiceContext struct {
	Config       config.Config
	Conn         sqlx.SqlConn
	FilesModel   models.FilesModel
	FolderModel  models.FoldersModel
	StorageModel models.StorageModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := sqlx.NewSqlConn(c.Database.Driver, c.Database.DSN)
	return &ServiceContext{
		Config:       c,
		Conn:         conn,
		FilesModel:   models.NewFilesModel(conn, c.Cache),
		FolderModel:  models.NewFoldersModel(conn, c.Cache),
		StorageModel: models.NewStorageModel(conn),
	}
}
